package com.ucitymetro.ucitymc.autosecurity.utils;

import org.springframework.stereotype.Component;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

@Component
public class SHA1Utils {

    /**
     * 对字符串md5加密
     * @param content
     * @return String
     * @throws Exception
     */
    public static String encrypt(String content) throws Exception {
        try {
            MessageDigest sha1 = MessageDigest.getInstance("SHA1");
            return new String(sha1.digest(content.getBytes("UTF-8")));
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }
}